// 消息提示工具函数
import { ElMessage, ElMessageBox, ElNotification } from 'element-plus'

// 成功消息
export const successMessage = (message, duration = 3000) => {
  return ElMessage({
    message,
    type: 'success',
    duration,
    showClose: true
  })
}

// 错误消息
export const errorMessage = (message, duration = 3000) => {
  return ElMessage({
    message,
    type: 'error',
    duration,
    showClose: true
  })
}

// 警告消息
export const warningMessage = (message, duration = 3000) => {
  return ElMessage({
    message,
    type: 'warning',
    duration,
    showClose: true
  })
}

// 信息消息
export const infoMessage = (message, duration = 3000) => {
  return ElMessage({
    message,
    type: 'info',
    duration,
    showClose: true
  })
}

// 确认对话框
export const confirmDialog = (message, title = '提示', options = {}) => {
  return ElMessageBox.confirm(message, title, {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
    ...options
  })
}

// 确认对话框（成功样式）
export const confirmSuccessDialog = (message, title = '提示', options = {}) => {
  return ElMessageBox.confirm(message, title, {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'success',
    ...options
  })
}

// 确认对话框（危险样式）
export const confirmDangerDialog = (message, title = '提示', options = {}) => {
  return ElMessageBox.confirm(message, title, {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'error',
    ...options
  })
}

// 提示框（只显示确定按钮）
export const alertDialog = (message, title = '提示', options = {}) => {
  return ElMessageBox.alert(message, title, {
    confirmButtonText: '确定',
    type: 'info',
    ...options
  })
}

// 提示框（成功样式）
export const alertSuccessDialog = (message, title = '提示', options = {}) => {
  return ElMessageBox.alert(message, title, {
    confirmButtonText: '确定',
    type: 'success',
    ...options
  })
}

// 提示框（危险样式）
export const alertDangerDialog = (message, title = '提示', options = {}) => {
  return ElMessageBox.alert(message, title, {
    confirmButtonText: '确定',
    type: 'error',
    ...options
  })
}

// 输入框
export const promptDialog = (message, title = '提示', options = {}) => {
  return ElMessageBox.prompt(message, title, {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    ...options
  })
}

// 通知
export const notification = (title, message, type = 'info', duration = 4500, offset = 0) => {
  return ElNotification({
    title,
    message,
    type,
    duration,
    offset,
    showClose: true
  })
}

// 成功通知
export const successNotification = (title, message, duration = 4500, offset = 0) => {
  return notification(title, message, 'success', duration, offset)
}

// 错误通知
export const errorNotification = (title, message, duration = 4500, offset = 0) => {
  return notification(title, message, 'error', duration, offset)
}

// 警告通知
export const warningNotification = (title, message, duration = 4500, offset = 0) => {
  return notification(title, message, 'warning', duration, offset)
}

// 信息通知
export const infoNotification = (title, message, duration = 4500, offset = 0) => {
  return notification(title, message, 'info', duration, offset)
}

// 关闭所有消息
export const closeAllMessages = () => {
  ElMessage.closeAll()
}

// 关闭所有通知
export const closeAllNotifications = () => {
  ElNotification.closeAll()
}